package com.wjk.cms.common;

import org.apache.commons.lang3.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class Channel {

    /**
     * NTC职业技能培训平台
     */
    public static final String NTC = "scm";

    public static String get(String defaultValue) {
        String channel = get();
        return StringUtils.isEmpty(channel) ? defaultValue : channel;
    }

    public static String get() {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        if (request == null) {
            return null;
        }
        return request.getHeader("channel");
    }

}
